1. Technical Field
The present invention relates generally to an improved data processing system and in particular to a method and apparatus for compiling instructions in a data processing system. Still more particularly, the present invention relates to a method and apparatus for just in time compilation of instructions in a data processing system.
2. Description of Related Art
In a procedural environment, the developer often writes an application by making a series of calls to library routines provided by the system (as well as to routines written by the developer). Conceptually, the developer""s code sits on top of the system code. The developer""s code can access all of the system""s services, but the system need know nothing about the developer""s code as they are insulated from one another by one or more API layers. The developer is responsible for providing the overall behavior and flow of control of the application, with the system providing at least some of the functionality.
The procedural approach (and its more disciplined offspring, structured programming) has produced major improvements in the quality of software over the last twenty years. However, its limitations are painfully apparent in the difficulty in extending and specializing functionality. Since procedural systems do not provide flexible interfaces, developers cannot selectively change or extend the structure or behavior.
Even when extensions and modifications are made in a procedural application, it is hard to ensure that the changes will interoperate correctly with other systems that depend on the modifications. A typical result is that the solutions from one developer might not have anything in common with any other developer""s solutions. Instead of a small team of experts solving a particular problem once, there arc numerous teams repeatedly and unsatisfactorily (at least insofar as interoperability) addressing the same problem.
With the minimal reuse of code in a procedural system, maintenance requirements increase due to the greater amount of coding involved and the subsequent increased potential for introducing new bugs. This lack of extensibility, factorability, interoperability, and maintainability adds up to lower code and design reuse. The result is that developer productivity is severely hindered since more time and resources are spent writing code instead of solving new problems.
On the other hand, object-oriented environments solve many of the problems associated with procedural programming. Unlike procedural programming environments, which emphasize algorithms and procedures, object oriented environments emphasize the binding of data structures with the methods to operate on the data. The idea is to design object classes that correspond to the essential features of a problem. Object oriented programming includes inheritance, which allows derivation new classes from existing ones to provide special purpose extensions and modifications from a set common objects available to all developers.
Object oriented environments include, for example, are typically polymorphic in nature, which provides flexibility to create multiple definitions for functions. This feature allows classes to be more general and hence more reusable. Polymorphism also allows new components and functions to be added easily and without disturbing the existing system. Implementing software in object oriented environments makes it possible to design software that is more extensible, reusable, and maintainable.
JAVA is an object oriented programming language and environment that is designed to solve a number of problems in modem programming practice. JAVA is able to support applications for many types of data processing systems, which may contain a variety of central processing units and operating systems architectures. To enable a JAVA application to execute on different types of data processing systems, a compiler typically generates an architecture-neutral file format the compiled code is executable on many processors, given the presence of the JAVA run time system. The JAVA compiler generates bytecode instructions that are non-specific to a particular computer architecture. A bytecode is a machine independent code generated by the JAVA compiler and executed by a JAVA interpreter. A JAVA interpreter is a module that alternatively decodes and executes a bytecode or bytecodes. These bytecode instructions are designed to be easy to interpret on any machine and easily translated on the fly into native machine code.
Just in time (JIT) compilation involves taking bytecodes from the machine independent platform and converting them into machine code that runs on the current platform. Just in time compilation of JAVA bytecodes can provide impressive gains over interpretation in terms of performance. However, invariably, these gains come at the cost of increased storage utilization. Not only is the generated machine code larger than the original bytecode method, but typically the bytecode method is retained for reasons such as debug. Minimizing storage utilization is advantageous for any data processing system and is paramount for data processing systems, such as network computers, which do not employ virtual storage.
Presently available JIT compilers operate during class load or method invocation and compile entire methods. This includes all of the paths within each method whether or not they are used. Additionally, the output, compiled code of presently available JIT compilers are unable to smoothly transition between methods that are compiled through the just in time compiler or jitted and those that are interpreted. This inability to provide smooth transitions leads to jitting more methods than are needed for optimal performance.
Therefore, it would be advantageous to have an improved method and apparatus for JIT compilation of JAVA bytecodes.
One object of the present invention relates generally to an improved data processing system.
Another object of the present invention relates in particular to a method and apparatus for compiling instructions in a data processing system.
Yet another object of the present invention relates to a method and apparatus for just in time compilation of instructions in a data processing system.
The present invention provides a process in a data processing system for executing a method having a plurality of paths. The data processing system executes native machine code. A path is identified within the method that is being executed, wherein a plurality of bytecodes are associated with the path. Bytecodes are compiled for the path being executed, wherein the bytecodes are compiled into native machine code for the data processing system, wherein bytecodes for unexecuted paths remain uncompiled.
Under the present invention, methods may be partially compiled, leaving infrequently executed paths within the methods in bytecode form, reducing storage use. Compilation of bytecodes as a method is being interpreted resulting in just in time compilation of paths that are actually executed. Bytecodes for a path that is compiled may be used during the same invocation of the method containing the path during which compilation of the bytecodes are being performed.